﻿using CloudMusic.Helper;
using CloudMusic.Model;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Navigation;
using System.Windows.Media.Animation;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Threading;
using System.Linq;
using System.Collections.ObjectModel;
using System.Windows.Data;
using CloudMusic.UC;
using CloudMusic.ViewModel;
using CloudMusic.DicEventHelper;

namespace CloudMusic.View
{
    /// <summary>
    /// PageFindMusic.xaml 的交互逻辑
    /// </summary>
    public partial class PageFindMusic : Page
    {
        /// <summary>
        /// 标签每次移动的长度
        /// </summary>
        private double moveIndex;
        /// <summary>
        /// 标签总页数
        /// </summary>
        private int lbpage;
        /// <summary>
        /// 标签滑动时候当前的页数
        /// </summary>
        private int laPage = 1;
        /// <summary>
        /// 主播电台里面的听听模块内容暂存
        /// </summary>
        List<LiveDataClass> lt = new List<LiveDataClass>();
        /// <summary>
        /// 推荐mv内容暂存
        /// </summary>
        List<mvInfo> ml = new List<mvInfo>();
        /// <summary>
        /// 推荐的主播电台
        /// </summary>
        List<RcDJRadio> dj = new List<RcDJRadio>();
        /// <summary>
        /// 推荐页看看模块
        /// </summary>
        List<LiveDataClass> look = new List<LiveDataClass>();
        /// <summary>
        /// /每日推荐歌单数据
        /// </summary>
        List<RcmdSongs> rcmdSongs = new List<RcmdSongs>();
        /// <summary>
        /// 个性推荐台电
        /// </summary>
        List<HotCateModel> gxtj = new List<HotCateModel>();
        /// <summary>
        /// 创作翻唱
        /// </summary>
        List<HotCateModel> cf = new List<HotCateModel>();
        /// <summary>
        /// 3d电子
        /// </summary>
        List<HotCateModel> dz = new List<HotCateModel>();
        /// <summary>
        /// 音乐故事
        /// </summary>
        List<HotCateModel> yy = new List<HotCateModel>();
        /// <summary>
        /// 情感调频
        /// </summary>
        List<HotCateModel> qg = new List<HotCateModel>();
        /// <summary>
        /// 二次元
        /// </summary>
        List<HotCateModel> ec = new List<HotCateModel>();
        /// <summary>
        /// 飙升榜
        /// </summary>
        List<MusicModel> bs = new List<MusicModel>();
        /// <summary>
        /// 新歌榜
        /// </summary>
        List<MusicModel> xg = new List<MusicModel>();
        /// <summary>
        /// 原创榜
        /// </summary>
        List<MusicModel> yc = new List<MusicModel>();
        /// <summary>
        /// 热歌榜
        /// </summary>
        List<MusicModel> rg = new List<MusicModel>();
        //默认图片
        private string jpCover = @"pack://application:,,,/Image/jinping.png";
        //歌手
        private string singerCover = @"pack://application:,,,/Image/artist_rank.png";
        //类别
        private string tag;
        //
        private int limit = 99;
        //
        private int pages = 0;
        /// <summary>
        /// 分类
        /// </summary>
        private int type = -1;
        /// <summary>
        /// 筛选
        /// </summary>
        private string initial = "-1";
        /// <summary>
        /// 语种
        /// </summary>
        private int area = -1;
        /// <summary>
        /// 歌手页数
        /// </summary>
        private int singerPage = 1;
        /// <summary>
        /// 歌手头部
        /// </summary>
        private string singerPageHead = "";
        //private static BitmapImage jpCover = new BitmapImage(new Uri("pack://application:,,,/Resources/Image/jinping.png", UriKind.RelativeOrAbsolute));
        public PageFindMusic()
        {
            InitializeComponent();

            #region 推荐部分
            RecommendPart();
            SolePart();
            NewsMusic();
            RecommendMV();
            MV.Columns = 3;
            AnchorStation();
            Anchor.Columns = 5;
            ListenPart();
            LookPart();
            Look.Columns = 4;
            #endregion

            #region 歌单部分
            GetCatlist();
            GetHotCatlist();
            tag = "全部";
            GetSongSheetRect("全部", 99, 0);
            //this.itemsNum.ItemsSource = _collection;
            #endregion

            #region 电台部分
            //获取标签
            GetDJLable();
            toLeft.Visibility = Visibility.Collapsed;
            //获取听听
            GetDJListen();
            listenBtn.Columns = 5;
            //获取付费精品
            GetPaygift();
            //获取个性推荐
            GetDTGXTJ();
            //3D电子推荐
            GetElectron();
            //创作翻唱
            GetCF();
            //二次元
            GetEc();
            //情感调频
            GetEmotion();
            //音乐故事
            GetMusicHistory();

            #endregion

            #region 排行榜
            getGlobalList();
            #endregion

            #region 歌手
            GetSingerData(type, area, initial, 29, 0, 1);
            #endregion
            this.SizeChanged += MainWindow_Resize;
            //this.SizeChanged += new SizeChangedEventHandler(MainWindow_Resize);

        }

        #region 其它事件
        /// <summary>
        /// 注册事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region 歌单分页
            this.sheetpaging.PageCount = 1;
            this.sheetpaging.Page = 1;
            this.sheetpaging.RecordCount = 0;
            this.sheetpaging.PageSize = 100;
            this.sheetpaging.PageChanged += Sheetpaging_PageChanged;
            #endregion

            MusicViewModelBase.songListEvent += MusicViewModelBase_songListEvent; ;
            UCLogin.loginRecEvent += UCLogin_loginEvent;
            UCUserInfo.recLoginOut += UCUserInfo_recLoginOut;
            DicEvent.GoToView += DicEvent_GoToView;
            DicEvent.GoToJPView += DicEvent_GoToJPView;


        }
        /// <summary>
        /// 精品歌单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DicEvent_GoToJPView(object sender, EventArgs e)
        {
            var pb = new PageBoutiqueSheetViewModel(tag, 0);
            PageBoutiqueSheet pbs = new PageBoutiqueSheet(pb);
            NavigationService.Navigate(pbs);
        }

        private void DicEvent_GoToView(object sender, EventArgs e)
        {
            if (sender == null)
            {
                PageDaySongs pds = new PageDaySongs();
                NavigationService.Navigate(pds);
            }
            else
            {
                string tag = sender.ToString();
                JObject job = (JObject)JsonConvert.DeserializeObject(tag);
                int hq = job["highQuality"].ToString() == "False" ? 1 : 2;
                GoToPage(Convert.ToInt64(job["id"].ToString()), hq);
            }
        }
        /// <summary>
        /// 登出后的操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UCUserInfo_recLoginOut(object sender, EventArgs e)
        {
            RecommendPart();
        }

        /// <summary>
        /// 登录后数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UCLogin_loginEvent(object sender, EventArgs e)
        {
            RecommendPart();
        }

        private void MusicViewModelBase_songListEvent(object sender, EventArgs e)
        {
            long id = (long)sender;
            var item = ObjectToEntityHelper.ConvertObjectByJson<PlayModel>(bs);
            if (!PlayListHelper.MainMusicList.Any(t => t.Id == id))
            {
                item.ForEach(p => PlayListHelper.MainMusicList.Add(p));
            }
        }

        /// <summary>
        ///动态设置个数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainWindow_Resize(object sender, EventArgs e)
        {
            Button bt = default;
            var pss = DataContext as PageFindMusicViewModel;
            if (this.ActualWidth > 850)
            {
                pss.Colums = 5;

                pss.GlobalColuns = 6;

                pss.SingerColums = 6;
                #region 推荐MV
                MV.Columns = 4;
                bt = new Button { Style = TryFindResource("MVInfoStyle") as Style, DataContext = ml[3] };
                bt.Tag = ml[3].mvId;
                // bt.Click += new RoutedEventHandler(Btn_Click);
                MV.Children.Insert(MV.Children.Count, bt);
                #endregion

                #region 推荐的主播电台
                Anchor.Columns = 6;
                bt = new Button { Style = TryFindResource("AnchorBtnStyle") as Style, DataContext = dj[5] };
                bt.Tag = dj[5].id;
                //bt.Click += new RoutedEventHandler(Btn_Click);
                Anchor.Children.Insert(Anchor.Children.Count, bt);
                #endregion

                #region 推荐页面看看模块
                Look.Columns = 5;
                bt = new Button { Style = TryFindResource("LookInfoStyle") as Style, DataContext = look[4] };
                bt.Tag = look[4].webRoomUrl;
                bt.Click += Bt_Listen_Look_Click;
                Look.Children.Insert(Look.Children.Count, bt);
                #endregion

                #region 主播电台

                #region 标签
                for (int i = 0; i < lableBtn.Children.Count; i++)
                {
                    Thickness lb = new Thickness();
                    lb.Left = 42;
                    lableBtn.Children[i].SetValue(MarginProperty, lb);
                }
                moveIndex = cv.ActualWidth * laPage;
                #endregion

                #region  主播电台听听
                listenBtn.Columns = 6;
                bt = new Button { Style = TryFindResource("DJLableListenStyle") as Style, DataContext = lt[5] };
                bt.Tag = lt[5].webRoomUrl;
                bt.Click += Bt_Listen_Look_Click;
                listenBtn.Children.Insert(listenBtn.Children.Count, bt);
                #endregion

                #endregion

                #region 电台个性推荐
                personalityBtn.Columns = 6;
                bt = new Button { Style = TryFindResource("dtgxBtn") as Style, DataContext = gxtj[5] };
                bt.Tag = gxtj[5].id;
                // bt.Click += new RoutedEventHandler(Btn_Click);
                personalityBtn.Children.Insert(personalityBtn.Children.Count, bt);
                #endregion

                #region 创作翻唱
                cfBtn.Columns = 6;
                bt = new Button { Style = TryFindResource("dtgxBtn") as Style, DataContext = cf[5] };
                bt.Tag = cf[5].id;
                // bt.Click += new RoutedEventHandler(Btn_Click);
                cfBtn.Children.Insert(cfBtn.Children.Count, bt);
                #endregion

                #region 3d电子
                electronicsBtn.Columns = 6;
                bt = new Button { Style = TryFindResource("dtgxBtn") as Style, DataContext = dz[5] };
                bt.Tag = dz[5].id;
                // bt.Click += new RoutedEventHandler(Btn_Click);
                electronicsBtn.Children.Insert(electronicsBtn.Children.Count, bt);
                #endregion

                #region 音乐故事
                musicHistory.Columns = 6;
                bt = new Button { Style = TryFindResource("dtgxBtn") as Style, DataContext = yy[5] };
                bt.Tag = dz[5].id;
                // bt.Click += new RoutedEventHandler(Btn_Click);
                musicHistory.Children.Insert(musicHistory.Children.Count, bt);
                #endregion

                #region 情感调频
                emotion.Columns = 6;
                bt = new Button { Style = TryFindResource("dtgxBtn") as Style, DataContext = qg[5] };
                bt.Tag = dz[5].id;
                // bt.Click += new RoutedEventHandler(Btn_Click);
                emotion.Children.Insert(emotion.Children.Count, bt);
                #endregion

                #region 二次元
                erciyuan.Columns = 6;
                bt = new Button { Style = TryFindResource("dtgxBtn") as Style, DataContext = ec[5] };
                bt.Tag = dz[5].id;
                // bt.Click += new RoutedEventHandler(Btn_Click);
                erciyuan.Children.Insert(erciyuan.Children.Count, bt);
                #endregion

            }
            else
            {
                pss.GlobalColuns = 5;

                pss.Colums = 4;

                pss.SingerColums = 5;

                #region 推荐MV
                MV.Columns = 3;
                MV.Children.RemoveAt(MV.Children.Count - 1);
                #endregion

                #region 推荐的主播电台
                Anchor.Columns = 5;
                Anchor.Children.RemoveAt(Anchor.Children.Count - 1);
                #endregion

                #region 推荐页面看看模块
                Look.Columns = 4;
                Look.Children.RemoveAt(Look.Children.Count - 1);
                #endregion

                #region  主播电台

                #region 标签
                for (int i = 0; i < lableBtn.Children.Count; i++)
                {
                    Thickness lb = new Thickness();
                    lb.Left = 12;
                    lableBtn.Children[i].SetValue(MarginProperty, lb);
                }
                moveIndex = cv.ActualWidth * laPage;
                #endregion

                #region  主播电台听听
                listenBtn.Columns = 5;
                listenBtn.Children.RemoveAt(listenBtn.Children.Count - 1);
                #endregion

                #endregion

                #region 电台个性推荐
                personalityBtn.Columns = 5;
                personalityBtn.Children.RemoveAt(personalityBtn.Children.Count - 1);
                #endregion

                #region 创作翻唱
                cfBtn.Columns = 5;
                cfBtn.Children.RemoveAt(cfBtn.Children.Count - 1);
                #endregion

                #region 3d电子
                electronicsBtn.Columns = 5;
                electronicsBtn.Children.RemoveAt(electronicsBtn.Children.Count - 1);
                #endregion

                #region 音乐故事
                musicHistory.Columns = 5;
                musicHistory.Children.RemoveAt(musicHistory.Children.Count - 1);
                #endregion

                #region 情感调频
                emotion.Columns = 5;
                emotion.Children.RemoveAt(emotion.Children.Count - 1);
                #endregion

                #region 二次元
                erciyuan.Columns = 5;
                erciyuan.Children.RemoveAt(erciyuan.Children.Count - 1);
                #endregion
            }
        }
        /// <summary>
        /// listbox/listview/datagrid滚动关联
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            CommonHelper.RunScorllView(sender, e);
        }
        /// <summary>
        /// 根据歌单ID跳转到歌单详情页面
        /// </summary>
        /// <param name="id"></param>
        private void GoToPage(long id, int hq)
        {
            var ps = new PageSongSheetDetailViewModel(id, hq);
            PageSongSheetDetail pageSongSheetDetail = new PageSongSheetDetail(ps, id, hq);
            NavigationService.Navigate(pageSongSheetDetail);
        }
        /// <summary>
        /// 根据DJ标签ID跳转到对应的DJ页面
        /// </summary>
        /// <param name="id"></param>
        private void GoToDJPage(Int32 id)
        {
            var dj = new PageDJInfoViewModel(id);
            PageDJInfo dJInfo = new PageDJInfo(dj);
            NavigationService.Navigate(dJInfo);
        }

        /// <summary>
        /// 超链接事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            if (e.Uri != null && string.IsNullOrEmpty(e.Uri.OriginalString) == false)
            {
                string uri = e.Uri.AbsoluteUri;
                Process.Start(new ProcessStartInfo(uri));
                e.Handled = true;
            }
        }

        /// <summary>
        /// 推荐歌单信息长度设置
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        private string SetLength(string str)
        {
            if (str.Length > 20)
            {
                return str.Substring(0, 18) + "...";
            }
            else
            {
                return str;
            }
        }
        /// <summary>
        /// 更多按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void moreBtn_Click(object sender, MouseButtonEventArgs e)
        {
            (this.tabSongList.Items[1] as TabItem).IsSelected = true;
        }
        /// <summary>
        /// 每日歌曲
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void DaySong_Click(object sender, RoutedEventArgs e)
        //{
        //    PageDaySongs pds = new PageDaySongs();
        //    NavigationService.Navigate(pds);
        //}
        #endregion

        #region 个性推荐部分

        #region 推荐歌单部分

        private ObservableCollection<recommdData> item = null;
        private void RecommendPart()
        {
            item = new ObservableCollection<recommdData>();
            try
            {
                //Button bt = default;
                ////string cookie = "MUSIC_U=56418e440a522fbe7e0c533c21f2736679df3d2d50cdbf020bd4412c8f90af58e0235a7f03fa9bf1; Expires=Tue, 08-Sep-2020 03:01:41 GMT; Path=/;__remember_me=true; Expires=Tue, 08-Sep-2020 03:01:41 GMT; Path=/;__csrf=f34c9ce44fb09a491dd90874224ed935; Expires=Tue, 08-Sep-2020 03:01:51 GMT; Path=/";
                //string url = "";
                //if (PlayListHelper.UserInfos.Count == 0) url = "http://localhost:3000/personalized?limit=10";
                //else
                //{
                //    url = "http://localhost:3000/personalized?limit=9&cookie=" + PlayListHelper.UserInfos[0].Cookie;
                //    bt = new Button { Style = TryFindResource("DayInfoStyle") as Style };
                //    bt.Click += new RoutedEventHandler(DaySong_Click);
                //   // RecommendGrid.Children.Insert(0, bt);
                //}
                //var list = CommonHelper.GetEquipList<Recommend>(1, url);
                //if (list.code == 301) return;
                //for (int i = 0; i < list.result.Count; i++)
                //{
                //    RcmdSongs sl = new RcmdSongs();
                //    sl.playcount = CommonHelper.toNumber(list.result[i].playCount.ToString());
                //    sl.copywriter = SetLength(list.result[i].copywriter);
                //    sl.name = SetLength(list.result[i].name);
                //    sl.picUrl = list.result[i].picUrl;
                //    sl.id = list.result[i].id;
                //    bt = new Button { Style = TryFindResource("RecommendInfoStyle") as Style, DataContext = sl };
                //    bt.Tag = "{id:\"" + list.result[i].id + "\",highQuality:\"" + list.result[i].highQuality + "\"}";
                //    bt.Click += new RoutedEventHandler(RecommendPart_Btn_Click);
                //    //RecommendGrid.Children.Add(bt);
                //}
                string url = "";
                if (PlayListHelper.UserInfos.Count == 0)
                {
                    url = "http://localhost:3000/personalized?limit=10";
                    var list = CommonHelper.GetEquipList<Recommend>(1, url);
                    if (list.code == 301) return;
                    for (int i = 0; i < list.result.Count; i++)
                    {
                        item.Add(
                           new recommdData()
                           {
                               daysVis = Visibility.Collapsed,
                               recommdVis = Visibility.Visible,
                               data = new RcmdSongs()
                               {
                                   playcount = CommonHelper.toNumber(list.result[i].playCount.ToString()),
                                   copywriter = SetLength(list.result[i].copywriter),
                                   name = SetLength(list.result[i].name),
                                   picUrl = list.result[i].picUrl,
                                   id = list.result[i].id
                               }
                           });
                    }
                }
                else
                {
                    if (PlayListHelper.UserInfos[0].Cookie == "") return;
                    url = "http://localhost:3000/personalized?limit=9&cookie=" + PlayListHelper.UserInfos[0].Cookie;
                    var list = CommonHelper.GetEquipList<Recommend>(1, url);
                    if (list.code == 301) return;
                    item.Add(
                         new recommdData()
                         {
                             daysVis = Visibility.Visible,
                             recommdVis = Visibility.Collapsed,
                             week = DateTimeHelper.GetWeek(),
                             date = DateTimeHelper.GetDays(),
                             data = new RcmdSongs()
                             {
                                 name = "每日歌曲推荐",
                                 id = PlayListHelper.UserInfos[0].UserId
                             }
                         });
                    for (int i = 0; i < list.result.Count; i++)
                    {
                        item.Add(
                                new recommdData()
                                {
                                    daysVis = Visibility.Collapsed,
                                    recommdVis = Visibility.Visible,
                                    data = new RcmdSongs()
                                    {
                                        playcount = CommonHelper.toNumber(list.result[i].playCount.ToString()),
                                        copywriter = SetLength(list.result[i].copywriter),
                                        name = SetLength(list.result[i].name),
                                        picUrl = list.result[i].picUrl,
                                        id = list.result[i].id,
                                        tag = "{id:\"" + list.result[i].id + "\",highQuality:\"" + list.result[i].highQuality + "\"}"
                    }
                                });
                    }
                }
                this.recommdItemsControl.ItemsSource = item;
            }
            catch (Exception) { }

        }
        /// <summary>
        /// 滚动条联动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void myItemsControl_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            CommonHelper.RunScorllView(sender, e);
        }
        #endregion

        #region 独家放送
        private void SolePart()
        {
            Button bt = default;
            var list = CommonHelper.GetEquipList<Sole>(1, "http://localhost:3000/personalized/privatecontent");
            for (int i = 0; i < list.result.Length; i++)
            {
                bt = new Button { Style = TryFindResource("SoloInfoStyle") as Style, DataContext = list.result[i] };
                bt.Tag = list.result[i].id;
                //bt.Click += new RoutedEventHandler(Btn_Click);
                SoleGrid.Children.Add(bt);
            }

        }
        #endregion

        #region 最新音乐
        private void NewsMusic()
        {
            var list = CommonHelper.GetEquipList<Musics>(1, "http://localhost:3000/personalized/newsong");
            Button crl = default(Button);
            Border br = default(Border);
            for (int i = 0; i < 5; i++)
            {
                NewMusicGrid.RowDefinitions.Add(new RowDefinition());
            }
            for (int i = 0; i < 3; i++)
            {
                ColumnDefinition columnDefinition = new ColumnDefinition();
                if (i == 1)
                {
                    columnDefinition.Width = new GridLength(1);
                    columnDefinition.Cursor = Cursors.Arrow;
                }
                NewMusicGrid.ColumnDefinitions.Add(columnDefinition);
            }
            for (int x = 0; x < 3; x++)
            {
                int u = 0;
                if (x == 2)
                {
                    u += 5;
                }
                for (int y = 0; y < 5; y++)
                {
                    if (x != 1)
                    {
                        //序号
                        if (u < 10)
                        {
                            list.result[u].count = "0" + (u + 1);
                            if (u == 9)
                            {
                                list.result[u].count = (u + 1).ToString();
                            }
                        }
                        //是否为高音质
                        if (list.result[u].type == 4)
                        {
                            list.result[u].SQVis = "Visible";
                        }
                        else
                        {
                            list.result[u].SQVis = "Collapsed";
                        }
                        //是否有MV
                        if (list.result[u].song.mvid != 0)
                        {
                            list.result[u].VideoVis = "Visible";
                        }
                        else
                        {
                            list.result[u].VideoVis = "Collapsed";
                        }
                        //是否有相关解释
                        if (list.result[u].song.alias.Count != 0)
                        {
                            for (int j = 0; j < list.result[u].song.alias.Count; j++)
                            {
                                list.result[u].song.alias[j] = "(" + list.result[u].song.alias[j].ToString() + ")";
                                list.result[u].nameAlias = list.result[u].name + "(" + list.result[u].song.alias[j] + ")";
                            }
                        }
                        else
                        {
                            list.result[u].nameAlias = list.result[u].name;
                        }
                        crl = new Button { Style = TryFindResource("NewMusicBtnStyle") as Style, HorizontalContentAlignment = HorizontalAlignment.Stretch, DataContext = list.result[u] };
                        Grid.SetRow(crl, y);
                        Grid.SetColumn(crl, x);
                        NewMusicGrid.Children.Add(crl);
                        u++;
                    }
                    else
                    {
                        br = new Border { Background = new SolidColorBrush(Color.FromRgb(225, 225, 226)) };
                        Grid.SetRow(br, y);
                        Grid.SetColumn(br, x);
                        NewMusicGrid.Children.Add(br);
                    }
                }
            }
        }
        #endregion

        #region 推荐MV
        private void RecommendMV()
        {
            Button bt = default;
            var list = CommonHelper.GetEquipList<MV>(1, "http://localhost:3000/personalized/mv");
            mvInfo _mvInfo;
            for (int i = 0; i < list.result.Length; i++)
            {
                _mvInfo = new mvInfo();
                _mvInfo.playCount = CommonHelper.toNumber(list.result[i].playCount);
                _mvInfo.copywriter = list.result[i].copywriter.Replace("\r", string.Empty).Replace("\n", string.Empty).Replace("\t", string.Empty);
                _mvInfo.name = list.result[i].name;
                _mvInfo.artistName = list.result[i].artistName;
                _mvInfo.artistId = list.result[i].artistId;
                _mvInfo.mvId = list.result[i].id;
                _mvInfo.picUrl = list.result[i].picUrl;
                ml.Add(_mvInfo);
                bt = new Button { Style = TryFindResource("MVInfoStyle") as Style, DataContext = _mvInfo };
                bt.Tag = list.result[i].id;
                //bt.Click += new RoutedEventHandler(Btn_Click);
                MV.Children.Add(bt);
            }
        }
        #endregion

        #region 推荐主播电台
        private void AnchorStation()
        {
            Button bt = default;
            var list = CommonHelper.GetEquipList<RecommendedStationsModel>(1, "http://localhost:3000/personalized/djprogram");
            for (int i = 0; i < list.result.Count; i++)
            {
                RcDJRadio rcDJRadio = new RcDJRadio();
                rcDJRadio.id = list.result[i].program.radio.id;
                rcDJRadio.name = list.result[i].program.radio.name;
                rcDJRadio.picUrl = list.result[i].program.radio.picUrl;
                rcDJRadio.rcmdText = list.result[i].program.radio.rcmdText;
                if (list.result[i].program.radio.radioFeeType == 0)
                {
                    rcDJRadio.radioFeeTypeVis = "Collapsed";
                }
                else
                {
                    rcDJRadio.radioFeeTypeVis = "Visible";
                    rcDJRadio.radioFeeTypeText = "付费精品";
                }
                dj.Add(rcDJRadio);
                if (i < 6)
                {
                    bt = new Button { Style = TryFindResource("AnchorBtnStyle") as Style, DataContext = rcDJRadio };
                    bt.Tag = list.result[i].program.radio.id;
                    //bt.Click += new RoutedEventHandler(Btn_Click);
                    Anchor.Children.Add(bt);
                }
            }
        }
        #endregion

        #region 听听模块
        private void ListenPart()
        {

            var list = CommonHelper.GetEquipList<LookModel>(1, "https://api.iplay.163.com/api/livestream/listen/homepage/recommend/list?limit=5");
            LiveDataClass liveDataClass;
            Button bt = default;
            if (list.data == null) return;
            for (int i = 0; i < list.data.itemList.Count; i++)
            {
                liveDataClass = new LiveDataClass();
                if (list.data.itemList[i].liveData != null)
                {
                    if (list.data.itemList[i].liveData.activityBadge != null)
                    {
                        liveDataClass.content = list.data.itemList[i].liveData.activityBadge.content;
                        liveDataClass.contentVis = "Visible";
                    }
                    else
                    {
                        liveDataClass.contentVis = "Collapsed";
                    }
                    if (list.data.itemList[i].liveData.extendTag != null)
                    {
                        liveDataClass.extendTag = list.data.itemList[i].liveData.extendTag;
                        liveDataClass.extendTagVis = "Visible";
                    }
                    else
                    {
                        liveDataClass.extendTagVis = "Collapsed";
                    }
                    if (list.data.itemList[i].liveData.liveTag != null)
                    {
                        if (list.data.itemList[i].liveData.activityBadge == null)
                        {
                            liveDataClass.content = list.data.itemList[i].liveData.liveTag;
                            liveDataClass.contentVis = "Visible";
                        }
                    }
                    else
                    {
                        liveDataClass.liveTagVis = "Collapsed";
                    }
                    liveDataClass.liveCoverUrl = list.data.itemList[i].liveData.liveCoverUrl;
                    liveDataClass.liveTitle = list.data.itemList[i].liveData.liveTitle;
                    liveDataClass.nickname = list.data.itemList[i].liveData.userInfo.nickname;
                    liveDataClass.popularity = list.data.itemList[i].liveData.popularity;
                    liveDataClass.avatarUrl = list.data.itemList[i].liveData.userInfo.avatarUrl;
                    liveDataClass.webRoomUrl = list.data.itemList[i].liveData.webRoomUrl;
                    bt = new Button { Style = TryFindResource("ListenInfoStyle") as Style, DataContext = liveDataClass };
                    bt.Tag = list.data.itemList[i].liveData.webRoomUrl;
                    bt.Click += Bt_Listen_Look_Click;
                    Listen.Children.Add(bt);
                }
            }
        }
        #endregion

        #region 看看模块
        private void LookPart()
        {
            Button bt = default;
            //var strJosn = CommonHelper.Get("http://music.163.com/api/livestream/homepage/recommend?limit=5");
            //JObject obj = (JObject)JsonConvert.DeserializeObject(strJosn);
            //var d = obj["data"]["itemList"].ToString();
            //for (int i =0; i < d.Length; i++)
            //{
            //    JObject s = (JObject)JsonConvert.DeserializeObject(d[i].ToString());
            //}
            //var strJosn = CommonHelper.Get("http://music.163.com/api/livestream/homepage/recommend");
            var list = CommonHelper.GetEquipList<LookModel>(1, "http://music.163.com/api/livestream/homepage/recommend?limit=5");
            LiveDataClass liveDataClass;
            for (int i = 0; i < list.data.itemList.Count; i++)
            {
                liveDataClass = new LiveDataClass();
                if (list.data.itemList[i].liveData != null)
                {
                    if (list.data.itemList[i].liveData.activityBadge != null)
                    {
                        liveDataClass.content = list.data.itemList[i].liveData.activityBadge.content;
                        liveDataClass.contentVis = "Visible";
                    }
                    else
                    {
                        liveDataClass.contentVis = "Collapsed";
                    }
                    if (list.data.itemList[i].liveData.extendTag != null)
                    {
                        liveDataClass.extendTag = list.data.itemList[i].liveData.extendTag;
                        liveDataClass.extendTagVis = "Visible";
                    }
                    else
                    {
                        liveDataClass.extendTagVis = "Collapsed";
                    }
                    liveDataClass.liveCoverUrl = list.data.itemList[i].liveData.liveCoverUrl;
                    liveDataClass.liveTitle = list.data.itemList[i].liveData.liveTitle;
                    liveDataClass.nickname = list.data.itemList[i].liveData.userInfo.nickname;
                    liveDataClass.popularity = list.data.itemList[i].liveData.popularity;
                    liveDataClass.avatarUrl = list.data.itemList[i].liveData.userInfo.avatarUrl;
                    liveDataClass.webRoomUrl = list.data.itemList[i].liveData.webRoomUrl;
                    look.Add(liveDataClass);
                    bt = new Button { Style = TryFindResource("LookInfoStyle") as Style, DataContext = liveDataClass };
                    bt.Tag = list.data.itemList[i].liveData.webRoomUrl;
                    bt.Click += Bt_Listen_Look_Click;
                    Look.Children.Add(bt);
                }
            }
        }

        private void Bt_Listen_Look_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            if (button.Tag != null)
            {
                Process.Start(new ProcessStartInfo(button.Tag.ToString()));
                e.Handled = true;
            }
        }
        #endregion

        #endregion

        #region 歌单部分
        /// <summary>
        /// 点击获取数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void CatListSong_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    int i = catListSong.SelectedIndex;
        //    catListSong.SelectedIndex = i;
        //    if (catListSong.SelectedIndex != -1)
        //    {
        //        HotSongListInfo o = (HotSongListInfo)catListSong.SelectedItem;
        //        if (o == null) return;
        //        if (o.id == 0)
        //        {
        //            var pb = new PageBoutiqueSheetViewModel(tag, 0);
        //            PageBoutiqueSheet pbs = new PageBoutiqueSheet(pb);
        //            NavigationService.Navigate(pbs);
        //        }
        //        else
        //        {
        //            int hq = o.HighQuality == false ? 1 : 2;
        //            GoToPage(o.id, hq);
        //        }
        //    }
        //    if (catListSong.SelectedIndex == -1) return;
        //    catListSong.SelectedIndex = -1;
        //}
        /// <summary>
        /// 获取标签
        /// </summary>
        public void GetCatlist()
        {
            var list = CommonHelper.GetEquipList<CatlistModel>(1, "http://localhost:3000/playlist/catlist");
            all.DataContext = list.all;
            for (int i = 0; i < list.categories.ToString().Length; i++)
            {
                List<subItem> _item = new List<subItem>();
                for (int j = 0; j < list.sub.Length; j++)
                {
                    if (list.sub[j].category.ToString() == i.ToString())
                    {
                        subItem item = new subItem();
                        item.name = list.sub[j].name;
                        item.resourceCount = list.sub[j].resourceCount;
                        item.imgId = list.sub[j].imgId;
                        item.imgUrl = list.sub[j].imgUrl;
                        item.type = list.sub[j].type;
                        item.category = list.sub[j].category;
                        item.resourceType = list.sub[j].resourceType;
                        item.hot = list.sub[j].hot;
                        item.activity = list.sub[j].activity;
                        _item.Add(item);
                    }
                }
                if (i == 0)
                {
                    Button bt = default;
                    for (int j = 0; j < _item.Count; j++)
                    {
                        bt = new Button { Style = FindResource("HotLabel") as Style, DataContext = _item[j] };
                        bt.Tag = _item[j].name;
                        bt.Click += _Click;
                        listview_Languages.Children.Add(bt);
                    }
                }
                if (i == 1)
                {
                    Button bt = default;
                    for (int j = 0; j < _item.Count; j++)
                    {
                        bt = new Button { Style = FindResource("HotLabel") as Style, DataContext = _item[j] };
                        bt.Tag = _item[j].name;
                        bt.Click += _Click;
                        listview_Style.Children.Add(bt);
                    }
                }
                if (i == 2)
                {
                    Button bt = default;
                    for (int j = 0; j < _item.Count; j++)
                    {
                        bt = new Button { Style = FindResource("HotLabel") as Style, DataContext = _item[j] };
                        bt.Tag = _item[j].name;
                        bt.Click += _Click;
                        listview_Scene.Children.Add(bt);
                    }
                }
                if (i == 3)
                {
                    Button bt = default;
                    for (int j = 0; j < _item.Count; j++)
                    {
                        bt = new Button { Style = FindResource("HotLabel") as Style, DataContext = _item[j] };
                        bt.Tag = _item[j].name;
                        bt.Click += _Click;
                        listview_Emotion.Children.Add(bt);
                    }
                }
                if (i == 4)
                {
                    Button bt = default;
                    for (int j = 0; j < _item.Count; j++)
                    {
                        bt = new Button { Style = FindResource("HotLabel") as Style, DataContext = _item[j] };
                        bt.Tag = _item[j].name;
                        bt.Click += _Click;
                        listview_Theme.Children.Add(bt);
                    }
                }
            }
        }
        /// <summary>
        /// 标签点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            this.sheetpaging.Page = 1;
            //btn.Background = new SolidColorBrush(Colors.Red);
            tag = btn.Tag.ToString();
            openData.Content = btn.Tag.ToString();
            OpenData_Click(sender, e);
            GetSongSheetRect(tag, 99, 0);
        }
        /// <summary>
        /// 全部标签按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void All_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            this.sheetpaging.Page = 1;
            tag = "全部歌单";
            openData.Content = "全部歌单";
            OpenData_Click(sender, e);
            GetSongSheetRect("全部", 99, 0);
        }
        /// <summary>
        /// 得到热门标签
        /// </summary>
        private void GetHotCatlist()
        {
            Button bt = default;
            var list = CommonHelper.GetEquipList<HotPlaylistModel>(1, "http://localhost:3000/playlist/hot");
            for (int i = 0; i < list.tags.Length; i++)
            {
                bt = new Button { Style = FindResource("HotLabelBtn") as Style, DataContext = list.tags[i] };
                bt.Tag = list.tags[i].name;
                bt.Click += HotCat_Click;
                HotCatList.Children.Add(bt);
            }
        }
        /// <summary>
        /// 热门标签点击获取数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HotCat_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            this.sheetpaging.Page = 1;
            openData.Content = btn.Tag.ToString();
            tag = btn.Tag.ToString();
            GetSongSheetRect(tag, 99, 0);
        }
        /// <summary>
        /// 歌单详情跳转
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Click_SongList(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            //GoToPage(Convert.ToInt64(button.Uid));
        }
        /// <summary>
        /// 标签也显示与否
        /// </summary>
        private bool open = true;
        private void OpenData_Click(object sender, RoutedEventArgs e)
        {
            if (open)
            {
                labListBtn.Visibility = Visibility.Visible;
                open = !open;
                return;
            }
            labListBtn.Visibility = Visibility.Collapsed;
            open = !open;
        }
 
        private ObservableCollection<songSheetData> songsItem = null;
        /// <summary>
        /// 获取歌单数据
        /// </summary>
        public void GetSongSheetRect(string tag, int limit, int offset)
        {
            this.catListSong.Dispatcher.BeginInvoke(new Action(() =>
            {
                songsItem = new ObservableCollection<songSheetData>();
                string url = "";
                if (PlayListHelper.UserInfos.Count == 0) url = "http://localhost:3000/top/playlist?order=hot&cat=" + tag + "&limit=" + limit + "&offset=" + offset;
                else url = "http://localhost:3000/top/playlist?order=hot&cat=" + tag + "&limit=" + limit + "&offset=" + offset + "&cookie=" + PlayListHelper.UserInfos[0].Cookie;
                var list = CommonHelper.GetEquipList<HotSongList>(1, url);
                HotSongListInfo hotSongListInfo;
                pages = list.total;
                this.sheetpaging.RecordCount = list.total;
                //List<HotSongListInfo> _hotSongListInfos = new List<HotSongListInfo>();
                if (this.sheetpaging.Page == 1)
                {
                    hotSongListInfo = new HotSongListInfo();
                    hotSongListInfo.coverImgUrl = jpCover;
                    hotSongListInfo.name = "精品歌单推荐，给最懂音乐的你";
                    hotSongListInfo.id = 0;
                    songsItem.Add(new songSheetData {
                        jpVis = Visibility.Visible,
                        songsdata = hotSongListInfo
                    });
                }
                for (int i = 0; i < list.playlists.Count; i++)
                {
                    hotSongListInfo = new HotSongListInfo();
                    hotSongListInfo.HighQuality = list.playlists[i].highQuality;
                    hotSongListInfo.coverImgUrl = list.playlists[i].coverImgUrl;
                    hotSongListInfo.playCount = CommonHelper.GetPlayCount(list.playlists[i].playCount);
                    hotSongListInfo.nickname = SetNameLength(list.playlists[i].creator.nickname);
                    hotSongListInfo.name = list.playlists[i].name;
                    hotSongListInfo.allName = list.playlists[i].creator.nickname;
                    hotSongListInfo.starsVis = CommonHelper.GetStarsVis(list.playlists[i].creator.userType);
                    hotSongListInfo.vVis = CommonHelper.GetVVis(list.playlists[i].creator.userType);
                    hotSongListInfo.musicVis = CommonHelper.GetMusicVis(list.playlists[i].creator.userType);
                    hotSongListInfo.id = list.playlists[i].id;
                    hotSongListInfo.topVis = Visibility.Visible;
                    hotSongListInfo.Tag = "{id:\"" + list.playlists[i].id + "\",highQuality:\"" + list.playlists[i].highQuality + "\"}";
                    songsItem.Add(new songSheetData
                    {
                        jpVis = Visibility.Collapsed,
                        songsdata = hotSongListInfo
                    });
                }
                catListSong.ItemsSource = songsItem;
            }));
        }
        /// <summary>
        /// 设置歌单里面的昵称的长度
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public string SetNameLength(string name)
        {
            if (name.Length > 6)
            {
                return name.Substring(0, 6) + "...";
            }
            else
            {
                return name;
            }
        }
        /// <summary>
        /// 歌单分页数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Sheetpaging_PageChanged(object sender, UC.PageChangedEventArgs e)
        {
            if (e.Page == 1)
            {
                GetSongSheetRect(tag, 99, 0);
            }
            else
            {
                GetSongSheetRect(tag, 100, (e.Page - 1) * 100);
            }
            sc.ScrollToVerticalOffset(0);
        }
        /// <summary>
        /// 获取收藏这总数-点击进来后获取
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sheet_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            this.sheetpaging.RecordCount = (long)pages;
        }
        #endregion

        #region 主播电台
        /// <summary>
        /// 获取电台的标签
        /// </summary>
        public void GetDJLable()
        {
            Button bt = default;
            var list = CommonHelper.GetEquipList<DJLableModel>(1, "http://localhost:3000/dj/catelist");
            for (int i = 0; i < list.categories.Count; i++)
            {
                bt = new Button { Style = TryFindResource("DJLableButtonStyle") as Style, DataContext = list.categories[i] };
                bt.Tag = list.categories[i].id;
                bt.Click += DJ_Bt_Click;
                lableBtn.Children.Add(bt);
            }
            //在第一个插入（排行榜）
            bt = new Button { Style = TryFindResource("DJLablePHBtn") as Style };
            bt.Click += Bt_Click_PH;
            lableBtn.Children.Insert(0, bt);
            //最后一个插入（我要做主播）
            bt = new Button { Style = TryFindResource("DJLableZBBtn") as Style };
            bt.Click += Bt_Click_ZB;
            lableBtn.Children.Insert(lableBtn.Children.Count, bt);
            lbpage = Convert.ToInt16(Math.Ceiling((double)lableBtn.Children.Count / 9));
            //index = cv.ActualWidth;
        }

        /// <summary>
        /// 
        /// </summary>
        private void GetDJListen()
        {

            var list = CommonHelper.GetEquipList<LookModel>(1, "https://api.iplay.163.com/api/livestream/listen/homepage/recommend/list?limit=6");
            LiveDataClass liveDataClass;
            Button bt = default;
            listenBtn.Columns = 5;
            if (list.data == null) return;
            for (int i = 0; i < list.data.itemList.Count; i++)
            {
                liveDataClass = new LiveDataClass();
                if (list.data.itemList[i].liveData != null)
                {
                    if (list.data.itemList[i].liveData.liveTag != null)
                    {
                        liveDataClass.liveTag = list.data.itemList[i].liveData.liveTag;
                        liveDataClass.liveTagVis = "Visible";
                    }
                    else
                    {
                        liveDataClass.liveTagVis = "Collapsed";
                    }
                    liveDataClass.liveCoverUrl = list.data.itemList[i].liveData.liveCoverUrl;
                    liveDataClass.liveTitle = list.data.itemList[i].liveData.liveTitle;
                    liveDataClass.nickname = list.data.itemList[i].liveData.userInfo.nickname;
                    liveDataClass.popularity = list.data.itemList[i].liveData.popularity;
                    liveDataClass.avatarUrl = list.data.itemList[i].liveData.userInfo.avatarUrl;
                    liveDataClass.webRoomUrl = list.data.itemList[i].liveData.webRoomUrl;
                    lt.Add(liveDataClass);
                    bt = new Button { Style = TryFindResource("DJLableListenStyle") as Style, DataContext = liveDataClass };
                    bt.Tag = list.data.itemList[i].liveData.webRoomUrl;
                    bt.Click += Bt_Listen_Look_Click;
                    listenBtn.Children.Add(bt);
                }
            }

        }
        /// <summary>
        /// 获取付费精品
        /// </summary>
        public void GetPaygift()
        {
            var list = CommonHelper.GetEquipList<PayModel>(1, "http://localhost:3000/dj/paygift?limit=4");
            Button bt = default;
            if (list.data == null) return;
            for (int i = 0; i < list.data.list.Count; i++)
            {
                PayModelInfo payModelInfo = new PayModelInfo();
                payModelInfo.id = list.data.list[i].id;
                payModelInfo.name = list.data.list[i].name;
                payModelInfo.picUrl = list.data.list[i].picUrl;
                payModelInfo.originalPrice = CommonHelper.SetPayInfo(list.data.list[i].originalPrice);
                payModelInfo.rcmdText = list.data.list[i].rcmdText;
                payModelInfo.lastProgramName = list.data.list[i].lastProgramName;
                payModelInfo.updataTime = DateTimeHelper.ConvertTimeStampToDateTime(GetUpdataTimeById(list.data.list[i].id)).ToString("yyyy年MM月dd日更新");
                bt = new Button { Style = FindResource("DJPayStyle") as Style, DataContext = payModelInfo };
                bt.Tag = list.data.list[i].id;
                payBtn.Children.Add(bt);
            }
        }
        /// <summary>
        /// 根据id获取付费精品更新时间时间
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private long GetUpdataTimeById(long id)
        {
            if (id != 0)
            {
                var strJosn = CommonHelper.Get("http://localhost:3000/dj/detail?rid=" + id);
                JObject obj = (JObject)JsonConvert.DeserializeObject(strJosn);
                return (long)obj["data"]["lastProgramCreateTime"];

                //JObject Data = (JObject)JsonConvert.DeserializeObject(data);
            }
            return 0;
        }
        /// <summary>
        /// 个性推荐电台数据
        /// </summary>
        public void GetDTGXTJ()
        {
            GXTJRoot list = null;
            if (PlayListHelper.UserInfos.Count > 0)
            {
                list = CommonHelper.GetEquipList<GXTJRoot>(1, "http://localhost:3000/dj/personalize/recommend?cookie=" + PlayListHelper.UserInfos[0].Cookie);
            }
            else
            {
                list = CommonHelper.GetEquipList<GXTJRoot>(1, "http://localhost:3000/dj/personalize/recommend?cookie=");
            }
            Button bt = default;
            for (int i = 0; i < list.data.Count; i++)
            {
                gxtj.Add(new HotCateModel
                {
                    id = list.data[i].id,
                    name = list.data[i].name,
                    picUrl = list.data[i].picUrl,
                    rcmdtext = list.data[i].rcmdText
                });
                if (i == 6) return;
                HotCateModel GXTJModel = new HotCateModel();
                GXTJModel.id = list.data[i].id;
                GXTJModel.name = list.data[i].name;
                GXTJModel.picUrl = list.data[i].picUrl;
                GXTJModel.rcmdtext = list.data[i].rcmdText;
                bt = new Button { Style = FindResource("dtgxBtn") as Style, DataContext = GXTJModel };
                bt.Tag = list.data[i].id;
                personalityBtn.Children.Add(bt);
            }
        }
        /// <summary>
        /// 创作翻唱
        /// </summary>
        public void GetCF()
        {
            HotCateRootModel list = null;
            if (PlayListHelper.UserInfos.Count > 0)
            {
                list = CommonHelper.GetEquipList<HotCateRootModel>(1, "http://localhost:3000/dj/radio/hot?cateId=2001&offset=0&limit=6&cookie=" + PlayListHelper.UserInfos[0].Cookie);
            }
            else
            {
                list = CommonHelper.GetEquipList<HotCateRootModel>(1, "http://localhost:3000/dj/radio/hot?cateId=2001&offset=0&limit=6&cookie=");
            }
            Button bt = default;
            for (int i = 0; i < 6; i++)
            {
                cf.Add(new HotCateModel
                {
                    id = list.djRadios[i].id,
                    name = list.djRadios[i].name,
                    picUrl = list.djRadios[i].picUrl,
                    rcmdtext = list.djRadios[i].rcmdtext
                });
                if (i > 5) return;
                HotCateModel hotCateModel = new HotCateModel();
                hotCateModel.id = list.djRadios[i].id;
                hotCateModel.name = list.djRadios[i].name;
                hotCateModel.picUrl = list.djRadios[i].picUrl;
                hotCateModel.rcmdtext = list.djRadios[i].rcmdtext;
                bt = new Button { Style = FindResource("dtgxBtn") as Style, DataContext = hotCateModel };
                bt.Tag = list.djRadios[i].id;
                cfBtn.Children.Add(bt);
            }
        }
        /// <summary>
        /// 3d电子
        /// </summary>
        public void GetElectron()
        {
            HotCateRootModel list = null;
            if (PlayListHelper.UserInfos.Count > 0)
            {
                list = CommonHelper.GetEquipList<HotCateRootModel>(1, "http://localhost:3000/dj/radio/hot?cateId=10002&offset=0&limit=6&cookie=" + PlayListHelper.UserInfos[0].Cookie);
            }
            else
            {
                list = CommonHelper.GetEquipList<HotCateRootModel>(1, "http://localhost:3000/dj/radio/hot?cateId=10002&offset=0&limit=6&cookie=");
            }
            Button bt = default;
            for (int i = 0; i < 6; i++)
            {
                dz.Add(new HotCateModel
                {
                    id = list.djRadios[i].id,
                    name = list.djRadios[i].name,
                    picUrl = list.djRadios[i].picUrl,
                    rcmdtext = list.djRadios[i].rcmdtext,
                    price = list.djRadios[i].price
                });
                if (i > 5) return;
                HotCateModel hotCateModel = new HotCateModel();
                hotCateModel.id = list.djRadios[i].id;
                hotCateModel.name = list.djRadios[i].name;
                hotCateModel.picUrl = list.djRadios[i].picUrl;
                hotCateModel.rcmdtext = list.djRadios[i].rcmdtext;
                hotCateModel.price = list.djRadios[i].price;
                bt = new Button { Style = FindResource("dtgxBtn") as Style, DataContext = hotCateModel };
                bt.Tag = list.djRadios[i].id;
                electronicsBtn.Children.Add(bt);
            }
        }
        /// <summary>
        /// 音乐故事
        /// </summary>
        public void GetMusicHistory()
        {
            HotCateRootModel list = null;
            if (PlayListHelper.UserInfos.Count > 0)
            {
                list = CommonHelper.GetEquipList<HotCateRootModel>(1, "http://localhost:3000/dj/radio/hot?cateId=2&offset=0&limit=6&cookie=" + PlayListHelper.UserInfos[0].Cookie);
            }
            else
            {
                list = CommonHelper.GetEquipList<HotCateRootModel>(1, "http://localhost:3000/dj/radio/hot?cateId=2&offset=0&limit=6&cookie=");
            }
            Button bt = default;
            for (int i = 0; i < 6; i++)
            {
                yy.Add(new HotCateModel
                {
                    id = list.djRadios[i].id,
                    name = list.djRadios[i].name,
                    picUrl = list.djRadios[i].picUrl,
                    rcmdtext = list.djRadios[i].rcmdtext,
                    price = list.djRadios[i].price
                });
                if (i > 5) return;
                HotCateModel hotCateModel = new HotCateModel();
                hotCateModel.id = list.djRadios[i].id;
                hotCateModel.name = list.djRadios[i].name;
                hotCateModel.picUrl = list.djRadios[i].picUrl;
                hotCateModel.rcmdtext = list.djRadios[i].rcmdtext;
                hotCateModel.price = list.djRadios[i].price;
                bt = new Button { Style = FindResource("dtgxBtn") as Style, DataContext = hotCateModel };
                bt.Tag = list.djRadios[i].id;
                musicHistory.Children.Add(bt);
            }
        }
        /// <summary>
        /// 情感调频
        /// </summary>
        public void GetEmotion()
        {
            HotCateRootModel list = null;
            if (PlayListHelper.UserInfos.Count > 0)
            {
                list = CommonHelper.GetEquipList<HotCateRootModel>(1, "http://localhost:3000/dj/radio/hot?cateId=3&offset=0&limit=6&cookie=" + PlayListHelper.UserInfos[0].Cookie);
            }
            else
            {
                list = CommonHelper.GetEquipList<HotCateRootModel>(1, "http://localhost:3000/dj/radio/hot?cateId=3&offset=0&limit=6&cookie=");
            }
            Button bt = default;
            for (int i = 0; i < 6; i++)
            {
                qg.Add(new HotCateModel
                {
                    id = list.djRadios[i].id,
                    name = list.djRadios[i].name,
                    picUrl = list.djRadios[i].picUrl,
                    rcmdtext = list.djRadios[i].rcmdtext,
                    price = list.djRadios[i].price
                });
                if (i > 5) return;
                HotCateModel hotCateModel = new HotCateModel();
                hotCateModel.id = list.djRadios[i].id;
                hotCateModel.name = list.djRadios[i].name;
                hotCateModel.picUrl = list.djRadios[i].picUrl;
                hotCateModel.rcmdtext = list.djRadios[i].rcmdtext;
                hotCateModel.price = list.djRadios[i].price;
                bt = new Button { Style = FindResource("dtgxBtn") as Style, DataContext = hotCateModel };
                bt.Tag = list.djRadios[i].id;
                emotion.Children.Add(bt);
            }
        }
        /// <summary>
        /// 二次元
        /// </summary>
        public void GetEc()
        {
            HotCateRootModel list = null;
            if (PlayListHelper.UserInfos.Count > 0)
            {
                list = CommonHelper.GetEquipList<HotCateRootModel>(1, "http://localhost:3000/dj/radio/hot?cateId=3001&offset=0&limit=6&cookie=" + PlayListHelper.UserInfos[0].Cookie);
            }
            else
            {
                list = CommonHelper.GetEquipList<HotCateRootModel>(1, "http://localhost:3000/dj/radio/hot?cateId=3001&offset=0&limit=6&cookie=");
            }
            Button bt = default;
            for (int i = 0; i < 6; i++)
            {
                ec.Add(new HotCateModel
                {
                    id = list.djRadios[i].id,
                    name = list.djRadios[i].name,
                    picUrl = list.djRadios[i].picUrl,
                    rcmdtext = list.djRadios[i].rcmdtext
                });
                if (i > 5) return;
                HotCateModel hotCateModel = new HotCateModel();
                hotCateModel.id = list.djRadios[i].id;
                hotCateModel.name = list.djRadios[i].name;
                hotCateModel.picUrl = list.djRadios[i].picUrl;
                hotCateModel.rcmdtext = list.djRadios[i].rcmdtext;
                bt = new Button { Style = FindResource("dtgxBtn") as Style, DataContext = hotCateModel };
                bt.Tag = list.djRadios[i].id;
                erciyuan.Children.Add(bt);
            }
        }

        /// <summary>
        /// 我要做主播
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Bt_Click_ZB(object sender, RoutedEventArgs e)
        {
            string uri = "https://music.163.com/st/radioweb/apply/";
            Process.Start(new ProcessStartInfo(uri));
            e.Handled = true;
        }
        /// <summary>
        /// 电台排行榜
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Bt_Click_PH(object sender, RoutedEventArgs e)
        {
            throw new NotImplementedException();
        }
        /// <summary>
        /// DJ标签点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DJ_Bt_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            GoToDJPage((Int32)btn.Tag);
        }

        /// <summary>
        /// 左移动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToLeft_Click(object sender, RoutedEventArgs e)
        {
            laPage--;
            if (laPage == 1)
            {
                toLeft.Visibility = Visibility.Collapsed;
                laPage = 1;
            }
            toRight.Visibility = Visibility.Visible;
            var animation = new DoubleAnimation()
            {
                From = -moveIndex,
                To = -moveIndex + cv.ActualWidth,
                SpeedRatio = 8,
            };
            myTranslateTransform.BeginAnimation(TranslateTransform.XProperty, animation);
            moveIndex -= cv.ActualWidth;
        }
        /// <summary>
        /// 右移动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToRight_Click(object sender, RoutedEventArgs e)
        {
            laPage++;
            moveIndex += cv.ActualWidth;
            if (laPage == lbpage)
            {
                toRight.Visibility = Visibility.Collapsed;
                laPage = lbpage;
            }
            toLeft.Visibility = Visibility.Visible;
            var animation = new DoubleAnimation()
            {
                From = -moveIndex + cv.ActualWidth,
                To = -moveIndex,
                SpeedRatio = 8,
            };
            myTranslateTransform.BeginAnimation(TranslateTransform.XProperty, animation);
        }
        /// <summary>
        /// 鼠标滚轮滑动翻页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cv_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            //if (e.Delta < 0)
            //{
            //    if (laPage >= 1 && laPage <= lbpage)
            //    {
            //        ToRight_Click(sender, e);
            //    }
            //}
            //else
            //{
            //    if (laPage >= 1)
            //    {
            //        ToLeft_Click(sender, e);
            //    }
            //}

        }
        /// <summary>
        /// 更多跳转到主播电台
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DJMoreBtn_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            (this.tabSongList.Items[2] as TabItem).IsSelected = true;
        }
        #endregion

        #region 排行榜

        /// <summary>
        /// 选中跳转到歌手详情页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SingerDetail_GotFocus(object sender, MouseButtonEventArgs e)
        {

        }

        /// <summary>
        /// 全球榜数据获取
        /// </summary>
        private void getGlobalList()
        {
            try
            {
                List<GlobalModel> globalModels = new List<GlobalModel>();
                Button bt = default;
                var list = "";
                JObject jo = (JObject)JsonConvert.DeserializeObject(CommonHelper.Get("http://localhost:3000/toplist"));
                var json = JsonConvert.SerializeObject(jo["list"].ToString());
                JsonReader reader = new JsonTextReader(new StringReader(json));
                while (reader.Read())
                {
                    list = reader.Value.ToString();
                }
                JArray jarray = (JArray)JsonConvert.DeserializeObject(list);
                //获取数值
                foreach (JObject jObject in jarray)
                {
                    globalModels.Add(new GlobalModel
                    {
                        id = Convert.ToInt64(jObject["id"].ToString()),
                        coverImgUrl = jObject["coverImgUrl"].ToString(),
                        name = jObject["name"].ToString(),
                        playCount = CommonHelper.toNumber(jObject["playCount"].ToString()),
                        updateTime = Convert.ToInt64(jObject["updateTime"].ToString())
                    });
                }
                //飙升榜
                bsTime.Text = DateTimeHelper.ConvertTimeStampToDateTime(globalModels[0].updateTime).ToString("MM月dd日更新");
                getList(globalModels[0].id, bs);
                bsMore.Tag = globalModels[0].id;
                //新歌榜
                xgTime.Text = DateTimeHelper.ConvertTimeStampToDateTime(globalModels[1].updateTime).ToString("MM月dd日更新");
                getList(globalModels[1].id, xg);
                xgMore.Tag = globalModels[1].id;
                //原创榜
                ycTime.Text = DateTimeHelper.ConvertTimeStampToDateTime(globalModels[2].updateTime).ToString("MM月dd日更新");
                getList(globalModels[2].id, yc);
                ycMore.Tag = globalModels[2].id;
                //新歌榜
                hotTime.Text = DateTimeHelper.ConvertTimeStampToDateTime(globalModels[3].updateTime).ToString("MM月dd日更新");
                getList(globalModels[3].id, rg);
                rgMore.Tag = globalModels[3].id;
                gsTime.Text = DateTimeHelper.GetMDays() + "更新";
                for (int i = 4; i < globalModels.Count; i++)
                {
                    bt = new Button { Style = TryFindResource("GlobBtnStyle") as Style, DataContext = globalModels[i] };
                    bt.Tag = globalModels[i].id;
                    bt.Click += Global_Btn_Click;

                    globalList.Children.Add(bt);
                }
            }
            catch (Exception ex)
            {
                string ss = ex.Message;
            }
        }
        /// <summary>
        /// 各个榜单进入到对应的歌单详情页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Global_Btn_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            GoToPage(Convert.ToInt64(button.Tag.ToString()), 1);
        }
        /// <summary>
        /// 歌曲性质列表
        /// </summary>
        List<PrivilegesItem> privilegesItems = null;
        /// <summary>
        /// 是否显示副标题
        /// </summary>
        private Visibility subVIS = Visibility.Collapsed;
        /// <summary>
        /// 选项卡选择事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tabSongList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                var data = tabSongList.SelectedItem as TabItem;
                singerPageHead = "";
                switch (data.Header.ToString())
                {
                    case "个性推荐":
                        break;
                    case "歌单":
                        break;
                    case "主播电台":
                        break;
                    case "排行榜":
                        break;
                    case "歌手":
                        singerPageHead = "歌手";
                        break;
                    case "最新音乐":
                        break;
                }
            }));
            e.Handled = true;
        }

        /// <summary>
        /// 获取对应的榜单歌曲--飙升/新歌等
        /// </summary>
        /// <param name="id"></param>
        /// <param name="models"></param>
        private void getList(long id, List<MusicModel> models)
        {
            Task.Run(async () =>
            {
                var strJosn = CommonHelper.Get("http://localhost:3000/playlist/detail?id=" + id);
                if (strJosn == "") return;
                JObject obj = (JObject)JsonConvert.DeserializeObject(strJosn);
                await Task.Run(() =>
                {
                    List<TrackIdsItem> trackIds = JsonConvert.DeserializeObject<List<TrackIdsItem>>(JsonConvert.SerializeObject(obj["playlist"]["trackIds"]));
                    string[] re = new string[2];
                    if (trackIds.Count > 800)
                    {
                        List<SongsRoot> SR = new List<SongsRoot>();
                        for (int i = 0; i < trackIds.Count; i++)
                        {
                            if (i < 700)
                            {
                                re[0] += trackIds[i].id.ToString() + ",";
                            }
                            else
                            {
                                re[1] += trackIds[i].id.ToString() + ",";
                            }
                        }
                        for (int i = 0; i < re.Length; i++)
                        {
                            var strSongJosn = CommonHelper.Get("http://localhost:3000/song/detail?ids=" + re[i].Substring(0, re[i].Length - 1));
                            SongsRoot sr = JsonConvert.DeserializeObject<SongsRoot>(strSongJosn);
                            SetList(sr, id, models, obj["playlist"]["name"].ToString());
                        }
                    }
                    else
                    {
                        string ids = null;
                        string Id = null;
                        for (int i = 0; i < trackIds.Count; i++)
                        {
                            Id += trackIds[i].id + ",";
                        }
                        ids = Id.Substring(0, Id.Length - 1);
                        var sr = CommonHelper.GetEquipList<SongsRoot>(1, "http://localhost:3000/song/detail?ids=" + ids);
                        SetList(sr, id, models, obj["playlist"]["name"].ToString());
                    }
                });
            });
        }

        /// <summary>
        /// 歌单歌曲列表数据封装
        /// </summary>
        /// <param name="sr"></param>
        /// <param name="id"></param>
        private void SetList(SongsRoot sr, long id, List<MusicModel> models, string source)
        {
            privilegesItems = new List<PrivilegesItem>();
            privilegesItems = sr.privileges;
            for (int i = 0; i < sr.songs.Count; i++)
            {
                for (int j = 0; j < privilegesItems.Count; j++)
                {
                    if (sr.songs[i].id == privilegesItems[j].id)
                    {
                        MusicModel data = new MusicModel
                        {
                            Index = i < 9 ? "0" + (i + 1).ToString() : i.ToString(),
                            Name = sr.songs[i].name.Trim(),
                            Subtitle = GetSubtitle(sr.songs[i].alia),
                            Id = sr.songs[i].id,
                            CoverTitle = CommonHelper.GetTitle(sr.songs[i].name, sr.songs[i].alia),
                            Artist = sr.songs[i].ar[0].name,
                            SingerId = sr.songs[i].ar[0].id,
                            Type = 1,
                            SongId = id,
                            Playing = false,
                            Source = source,
                            Album = sr.songs[i].al.name,
                            AlbumId = sr.songs[i].al.id,
                            PicUrl = sr.songs[i].al.picUrl,
                            CanPlay = true,
                            TimeStr = DateTimeHelper.GetTime((sr.songs[i].dt / 1000).ToString()),
                            MVVis = CommonHelper.GetMvVis(sr.songs[i].mv),
                            VIPVis = CommonHelper.GetVis(privilegesItems[j].fee),
                            STVis = CommonHelper.GetVis(privilegesItems[j].fee),
                            SQVis = CommonHelper.GetVis(privilegesItems[j].maxbr),
                            Pop = sr.songs[i].pop.ToString(),
                            ChargeInfoList = CommonHelper.GetChargeInfos(privilegesItems[j].chargeInfoList),
                            SubtitleVis = subVIS,
                        };
                        // ObservableCollection类型-- - 该类型的 CollectionView 不支持从调度程序线程以外的线程对其 SourceCollection 进行的更改, 解决方案
                        ThreadPool.QueueUserWorkItem(delegate
                        {
                            SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Application.Current.Dispatcher));
                            SynchronizationContext.Current.Post(pl =>
                            {
                                if (models == bs)
                                {
                                    bs.Add(data);
                                    bsList.ItemsSource = bs.Take(8);
                                }
                                else if (models == xg)
                                {
                                    xg.Add(data);
                                    xgList.ItemsSource = xg.Take(8);
                                }
                                else if (models == yc)
                                {
                                    yc.Add(data);
                                    ycList.ItemsSource = yc.Take(8);
                                }
                                else if (true)
                                {
                                    rg.Add(data);
                                    hotList.ItemsSource = rg.Take(8);
                                }
                                //models.Add(data);
                            }, null);
                        });
                    }
                }
            }
        }
        /// <summary>
        /// 副标题操作
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        private string GetSubtitle(List<string> str)
        {
            subVIS = Visibility.Collapsed;
            string al = null;
            if (str.Count > 0)
            {
                for (int i = 0; i < str.Count; i++)
                {
                    al += "(" + str[i] + ")";
                }
                subVIS = Visibility.Visible;
            }
            return al;
        }

        /// <summary>
        /// 各个榜单播放--飙升/热歌等
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PHPlayAllBtn_Click(object sender, RoutedEventArgs e)
        {
            Button bt = sender as Button;
            string tag = bt.Tag.ToString();
            switch (tag)
            {
                case "bs":
                    bsAllBtn.SetBinding(System.Windows.Controls.Primitives.ButtonBase.CommandParameterProperty, new Binding() { Source = bs });
                    break;
                case "xg":
                    xgAllBtn.SetBinding(System.Windows.Controls.Primitives.ButtonBase.CommandParameterProperty, new Binding() { Source = xg });
                    break;
                case "yc":
                    ycAllBtn.SetBinding(System.Windows.Controls.Primitives.ButtonBase.CommandParameterProperty, new Binding() { Source = yc });
                    break;
                case "rg":
                    rgAllBtn.SetBinding(System.Windows.Controls.Primitives.ButtonBase.CommandParameterProperty, new Binding() { Source = rg });
                    break;
                default:
                    break;
            }

        }

        /// <summary>
        /// 榜单更多
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void phbMore_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            long id = 0;
            switch (button.Name.ToString())
            {
                case " bsMore":
                    id = Convert.ToInt64(bsMore.Tag.ToString());
                    break;
                case " xgMore":
                    id = Convert.ToInt64(xgMore.Tag.ToString());
                    break;
                case " ycMore":
                    id = Convert.ToInt64(ycMore.Tag.ToString());
                    break;
                case " rgMore":
                    id = Convert.ToInt64(rgMore.Tag.ToString());
                    break;
                default:
                    break;
            }
            GoToPage(id, 1);
        }
        /// <summary>
        /// 榜单头部点击进入歌单详情页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void phbHeader_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Grid gd = sender as Grid;
            long id = 0;
            switch (gd.Tag.ToString())
            {
                case " bsHeader":
                    id = Convert.ToInt64(bsMore.Tag.ToString());
                    break;
                case " xgHeader":
                    id = Convert.ToInt64(xgMore.Tag.ToString());
                    break;
                case " ycHeader":
                    id = Convert.ToInt64(ycMore.Tag.ToString());
                    break;
                case " rgHeader":
                    id = Convert.ToInt64(rgMore.Tag.ToString());
                    break;
                default:
                    break;
            }
            GoToPage(id, 1);
        }
        /// <summary>
        /// 歌手
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gsMore_Click(object sender, RoutedEventArgs e)
        {

        }
        /// <summary>
        /// 歌手榜单页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gsHeader_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }


        #endregion

        #region 歌手

        private ObservableCollection<singerMode> singerItem = null;
        private void GetSingerData(int type, int area, string initial, int limit, int offset, int page)
        {
            this.catListSong.Dispatcher.BeginInvoke(new Action(() =>
            {
                singerItem = new ObservableCollection<singerMode>();
                string url = "http://localhost:3000/artist/list?type=" + type + "&area=" + area + "&initial=" + initial + "&limit=" + limit + "&offset=" + offset;
                //var list = CommonHelper.Get(url);
                //JObject obj = (JObject)JsonConvert.DeserializeObject(list);


                var list = CommonHelper.GetEquipList<SingerListModelRoot>(1, url);


                if (list.code !=200) return;
                if (list.more == false) return;
                if (singerPage == 1)
                {
                    singerItem.Add(new singerMode()
                    {
                        name = "歌手排行榜",
                        coverImgUrl = singerCover,
                        accountId = 0,
                        accountVis = false,
                        id = 0
                    });
                }
                for (int i = 0; i < list.artists.Count; i++)
                {
                    bool vis = false;
                    long acc = 0;
                    if (list.artists[i].accountId != 0)
                    {
                        vis = true;
                        acc = list.artists[i].accountId;
                    }
                    singerItem.Add(new singerMode()
                    {
                        accountId = acc,
                        accountVis = vis,
                        coverImgUrl = list.artists[i].picUrl,
                        id = list.artists[i].id,
                        name = list.artists[i].name,
                    });
                }
                singerList.ItemsSource = singerItem;

            }));

        }
        #endregion

        private void sc_ScrollChanged(object sender, ScrollChangedEventArgs e)
        {


            if (IsVerticalScrollBarAtButtom)
            {
                if (singerPageHead == "歌手")
                {
                    singerPage++;
                    GetSingerData(type, area, initial, 30, (singerPage-1)*30, 2);
                }
            }
        }
        /// <summary>
        /// 判断是否滚动到底
        /// </summary>
        public bool IsVerticalScrollBarAtButtom
        {
            get
            {
                bool isAtButtom = false;

                // get the vertical scroll position
                double dVer = sc.VerticalOffset;

                //get the vertical size of the scrollable content area
                double dViewport = sc.ViewportHeight;

                //get the vertical size of the visible content area
                double dExtent = sc.ExtentHeight;

                if (dVer != 0)
                {
                    if (dVer + dViewport == dExtent)
                    {
                        isAtButtom = true;
                    }
                    else
                    {
                        isAtButtom = false;
                    }
                }
                else
                {
                    isAtButtom = false;
                }

                if (sc.VerticalScrollBarVisibility == ScrollBarVisibility.Disabled || sc.VerticalScrollBarVisibility == ScrollBarVisibility.Hidden)
                {
                    isAtButtom = true;
                }

                return isAtButtom;
            }
        }
        /// <summary>
        /// 语言
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void languagesType_Click(object sender, RoutedEventArgs e)
        {
            RadioButton bt = sender as RadioButton;
            area = Convert.ToInt32(bt.Tag.ToString());
            singerPage = 1;
            GetSingerData(type, area, initial, 29, 0,1);
        }
        /// <summary>
        /// 分类
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void areaType_Click(object sender, RoutedEventArgs e)
        {
            RadioButton bt = sender as RadioButton;
            type = Convert.ToInt32(bt.Tag.ToString());
            singerPage = 1;
            GetSingerData(type, area, initial, 29, 0,1);
        }
        /// <summary>
        /// 筛选
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void screenType_Click(object sender, RoutedEventArgs e)
        {
            RadioButton bt = sender as RadioButton;
            initial = bt.Tag.ToString();
            singerPage = 1;
            GetSingerData(type, area, initial, 29, 0,1);
        }
    }
}
